package com.salton123.groupbargain.mvvm

import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.salton123.app.BaseApplication
import com.salton123.groupbargain.mvvm.model.BargainModel
import com.salton123.groupbargain.mvvm.viewmodel.BargainViewModel

/**
 * User: newSalton@outlook.com
 * Date: 2020-01-26 20:40
 * ModifyTime: 20:40
 * Description:
 */
object ViewModelFactory : ViewModelProvider.NewInstanceFactory() {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        if (modelClass.isAssignableFrom(BargainViewModel::class.java)) {
            return BargainViewModel(
                BaseApplication.sInstance,
                BargainModel(BaseApplication.sInstance)
            ) as T
        }
        throw IllegalArgumentException("Unknown ViewModel class: " + modelClass.name)
    }
}